Socket
Socket
Sign inDemoInstall

peer-id

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

peer-id

IPFS Peer Id implementation in Node.js


Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

peer-id JavaScript implementation

[ Build Status](https://travis-ci.org/diasdavid/js-peer-id) Dependency Status js-standard-style

IPFS Peer Id implementation in Node.js

Description

A IPFS Peer Id is based on a sha256 has of the peer public key, using multihash

Usage

Installing

$ npm install peer-id

Creating a new Id

var PeerId = require('ipfs-peer')

// Create a new Id
var id = new PeerId.create()

// Recreate an Id from Hex string
var id = new PeerId.createFromHexString(str)

// Recreate an Id from a Buffer
var id = new PeerId.createFromBytes(buf)

// Recreate an B58 String
var id = new PeerId.createFromB58String(str)

// Recreate from a Public Key
var id = new PeerId.createFromPubKey(pubKey)

// Recreate from a Private Key
var id = new PeerId.createFromPrivKey(privKey)

Exporting an Id

// Print friendly format
id.toPrint() // returns an object with id, privKey and pubKey in hex format

// Export to an hex string
id.toHexString()

// Export to Buffer
id.toBytes() (same as id.id)

// Export to a B58 string
id.toB58String()

Id format

id.pubKey   // Buffer containing the Public Key
id.privKey  // Buffer containing the Private Key
id.id       // Buffer containing the multihash

Keywords

FAQs

Package last updated on 28 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc